const {PORT} =  require("./utils/constant")

const express = require('express');

const cors = require("cors")

const app = express()

app.use(cors())

const path = require('path')
const bodyParser = require('body-parser');

// 使用body解析
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({extended:false}))

// 指定静态文件目录
app.use("/static",express.static('public'))

// 引入router
app.use('/file',require('./router/file'))
app.use("/user",require("./router/user"))
app.use("/pictures",require("./router/pictures"))
app.use("/case",require("./router/case"))

app.get("/",(req,res) => {
    res.redirect("/static/index.html")
})

app.get("/test",(req,res) => {
    res.send({
        code:200,
        msg:"测试",
        success:true,
    })
})


app.listen(PORT,() => {
    console.log(`服务器启动地址:http://localhost:${PORT}`);
})